﻿<cfsilent>
	<cfscript>

		event.setArg("pageTitle", "教学运行基础数据 - 培养方案修订 - 其他信息");

		sql = "	SELECT
					s.sbj_id,s.sbj_name,s.schooling_length
				FROM
					t_subject s
				WHERE
					s.sbj_id = :subjectId " ;
	
		queryObj = new Query( datasource=application.dnsSlave ) ;
		queryObj.addParam( name = "subjectId", value = event.getArg("SubID"), cfsqltype = "cf_sql_varchar" );
		rs_subjectEntity = queryObj.execute( sql=sql ).getResult();
		
		sql = "	SELECT
					sbj.sbj_id,sbj.sbj_name
				FROM
					t_subject sbj
				WHERE
					sbj.sbj_id LIKE :parent 
				ORDER BY
					sbj.sbj_id ASC";
		
		queryObj = new Query( datasource=application.dnsSlave );
		queryObj.addParam( name = "parent", value = rs_subjectEntity.sbj_id & '_', cfsqltype = "cf_sql_varchar" );
		rs_dir = queryObj.execute( sql=sql ).getResult();

		mathAdvice = getProperty("serviceFactory").getBean("senateMathAdvice");
		progressAdvice = getProperty("serviceFactory").getBean("graduateProgressAdvice");

		targetArgs = structNew();
		structInsert(targetArgs, "SubID", event.getArg("SubID"), true);
		structInsert(targetArgs, "Edition", event.getArg("Edition"), true);
		structInsert(targetArgs, "Schema", event.getArg("Schema"), true);

		passArgs = structNew();

		currentTab = event.getArg("TabID", "labProgress");

	</cfscript>
</cfsilent>

<div id="headArea">
	<div class="uiHeader uiHeaderWithImage ptm">
		<div class="clearfix uiHeaderTop">
			<div class="uiHeaderActions rfloat">
				<a class="uiButton" href="<cfoutput>#buildURL('programSchema')#</cfoutput>"><i class="mrs img btnList"></i><span class="uiButtonText">培养方案</span></a>
			</div>
			<div>
				<h2 class="uiHeaderTitle">
					<i class="uiHeaderImage img icon16x16 edit"></i>培养方案修订 - <cfoutput>#rs_subjectEntity.sbj_name#</cfoutput>专业(<cfoutput>#event.getArg("Edition")#</cfoutput>)版
				</h2>
			</div>
		</div>
	</div>
</div>

<!--- 加载导航菜单 --->
<!-- stepMenu-->
<cfoutput>#event.getArg("stepMenu")#</cfoutput>
<!--/stepMenu-->

<div class="UIElement">
	<ul class="senateFirstPage">
		<li>
			<div class="clearfix" id="summary">
				<div class="UItab2">
					<div class="tabLables">
						<span <cfif currentTab eq "labProgress">class="active"</cfif> id="labProgress" tabTarget="Progress">学习进度要求</span>
						<span <cfif currentTab eq "labCharge">class="active"</cfif> id="labCharge" tabTarget="Charge">专业学费</span>
					</div>
				</div>
				<script language="javascript" type="text/javascript">
					//<![CDATA[
					<!--
					$(document).ready(function() {
						
						/* init Tab */
						$("div.tabContent").hide();
						$("div#" + $("div.tabLables span.active").attr("tabTarget")).show();
						
						$("div.tabLables > span").click(function(){
							var $targetID = $(this).attr("tabTarget");
							
							$("div.tabLables span").removeClass("active");
							$(this).addClass("active");
							
							$("div.tabContent").not('[id="' + $targetID + '"]').hide();
							$("div.tabContent#" + $targetID).show();
						});
						
					});
					// -->
					//]]>
				</script>
				
				<div id="Progress" class="tabContent">
					
					
						<form id="formProgress" onSubmit="javascript:return processVerfiyForm('formProgress');" class="formWrapper" method="post" action="<cfoutput>#buildURL('programSchemaWizardProgressUpdateDo')#</cfoutput>">

							<input type="hidden" name="SubjectID" value="<cfoutput>#rs_subjectEntity.sbj_id#</cfoutput>" />
							<input type="hidden" name="Grade" value="<cfoutput>#event.getArg('Edition')#</cfoutput>" />
							
							<!--- 如果没有方向 则指向专业 --->
							<cfif rs_dir.recordCount eq 0>

                                <cfset sql = "	SELECT
													p.pgs_id,p.credit_required,p.credit_all
												FROM
													t_progress p
												WHERE
													p.pgs_id = :schema " />

                                <cfset queryObj = new Query( datasource = application.dnsSlave ) />
								<cfset queryObj.addParam( name = "schema", value = event.getArg("Schema"), cfsqltype = "cf_sql_varchar" )/>
                                <cfset rs_progressEntity = queryObj.execute( sql=sql ).getResult()/>

								<cfif rs_progressEntity.recordCount eq 0>

									<!--- 设置必修课学分设置的默认值 --->
                                    <cfset sql = "	SELECT
														s.term_index,SUM(c.course_credit) credit_sum
													FROM
														t_schema s
														INNER JOIN t_course c ON c.cid = s.cid
														INNER JOIN t_course_prop cp ON cp.prop_id = s.prop_id
													WHERE
														s.grade = :grade 
														AND
														s.sbj_id = :subjectId 
														AND
														s.prop_id = '1'
													GROUP BY
														s.term_index
													ORDER BY
														s.term_index" />
                                    
                                    <cfset queryObj = new Query( datasource = application.dnsSlave ) />
									<cfset queryObj.addParam( name = "grade", value = event.getArg("Edition"), cfsqltype = "cf_sql_char" )/>
                                    <cfset queryObj.addParam( name = "subjectId", value = event.getArg("SubID"), cfsqltype = "cf_sql_varchar" )/>
                                    <cfset rs_schemaCredit = queryObj.execute( sql=sql ).getResult()/>
                                    
                                    <cfloop query="rs_schemaCredit">
										<cfset progressAdvice.setCreditRequiredByTerm( rs_schemaCredit.term_index, rs_schemaCredit.credit_sum ) />
										<cfset progressAdvice.setCreditByTerm( rs_schemaCredit.term_index, rs_schemaCredit.credit_sum ) />
									</cfloop>
		
								<cfelse>
		
									<!--- 学分设置保存的值 --->
									<cfset progressAdvice.parseCreditRequired( rs_progressEntity.credit_required ) />
									<cfset progressAdvice.parseCredit( rs_progressEntity.credit_all ) />
		
								</cfif>
								
								<div class="label">
									<b><cfoutput>#rs_subjectEntity.sbj_name#</cfoutput></b>
									<table class="UItable">
										<tr align="center">
											<td class="cellBorderPadding">学期</td>
											<cfloop from="1" to="#(rs_subjectEntity.schooling_length*2)#" index="termIdx">
												<td class="cellBorderPadding"><cfoutput>#mathAdvice.convertTermIdxToChinese(termIdx)#</cfoutput></td>
											</cfloop>
										</tr>
										<tr align="center">
											<td class="cellBorder">必修课</td>
											<cfloop from="1" to="#(rs_subjectEntity.schooling_length*2)#" index="termIdx">
												<td class="cellBorderPadding"><span class="number"><input name="R<cfoutput>#numberFormat(termIdx, '0_')#</cfoutput>" class="typeTinyInt" verification="double" value="<cfoutput>#progressAdvice.getCreditRequiredByTerm(termIdx)#</cfoutput>" /></span></td>
											</cfloop>
										</tr>
										<tr align="center">
											<td class="cellBorder">总学分</td>
											<cfloop from="1" to="#(rs_subjectEntity.schooling_length * 2)#" index="termIdx">
												<td class="cellBorderPadding"><span class="number"><input name="A<cfoutput>#numberFormat(termIdx, '0_')#</cfoutput>" class="typeTinyInt" verification="double" value="<cfoutput>#progressAdvice.getCreditByTerm(termIdx)#</cfoutput>" /></span></td>
											</cfloop>
										</tr>
									</table>
								</div>
								
								
							</cfif>
							
							<!--- 如果有方向 --->
							<cfloop query="rs_dir">
                                <cfset sql = "	SELECT
													p.pgs_id,p.credit_required,p.credit_all
												FROM
													t_progress p
												WHERE
													p.pgs_id = :schema " />

                                <cfset queryObj = new Query( datasource = application.dnsSlave ) />
								<cfset queryObj.addParam( name = "schema", value = event.getArg("Edition") & rs_dir.sbj_id, cfsqltype = "cf_sql_varchar" )/>
                                <cfset rs_progressEntity = queryObj.execute( sql=sql ).getResult()/>
								
                                <cfif rs_progressEntity.recordCount eq 0>

									<!--- 设置必修课学分设置的默认值 --->
                                    <cfset sql = "	SELECT
														s.term_index,SUM(c.course_credit) credit_sum
													FROM
														t_schema s
														INNER JOIN t_course c ON c.cid = s.cid
														INNER JOIN t_course_prop cp ON cp.prop_id = s.prop_id
													WHERE
														s.grade = :grade 
														AND
														 	(s.sbj_id = :subjectId OR s.sbj_id = :subjectDir )
														AND
														s.prop_id = '1'
													GROUP BY
														s.term_index
													ORDER BY
														s.term_index" />
                                    
                                    <cfset queryObj = new Query( datasource = application.dnsSlave ) />
									<cfset queryObj.addParam( name = "grade", value = event.getArg("Edition"), cfsqltype = "cf_sql_char" )/>
                                    <cfset queryObj.addParam( name = "subjectId", value = event.getArg("SubID"), cfsqltype = "cf_sql_varchar" )/>
                                    <cfset queryObj.addParam( name = "subjectDir", value = rs_dir.sbj_id, cfsqltype = "cf_sql_varchar" )/>
                                    <cfset rs_schemaCredit = queryObj.execute( sql=sql ).getResult()/>

                                    <cfloop query="rs_schemaCredit">
										<cfset progressAdvice.setCreditRequiredByTerm(rs_schemaCredit.term_index, rs_schemaCredit.credit_sum) />
										<cfset progressAdvice.setCreditByTerm(rs_schemaCredit.term_index, rs_schemaCredit.credit_sum) />
									</cfloop>
		
								<cfelse>
									<!--- 学分设置保存的值 --->
                                    <cfset progressAdvice.parseCreditRequired( rs_progressEntity.credit_required ) />
									<cfset progressAdvice.parseCredit( rs_progressEntity.credit_all ) />
								</cfif>
							
								
							
								<div class="label">
									<b><cfoutput>#rs_dir.sbj_name#</cfoutput></b>
									<table class="UItable">
										<tr align="center">
											<td class="cellBorderPadding">学期</td>
											<cfloop from="1" to="#(rs_subjectEntity.schooling_length*2)#" index="termIdx">
												<td class="cellBorderPadding"><cfoutput>#mathAdvice.convertTermIdxToChinese(termIdx)#</cfoutput></td>
											</cfloop>
										</tr>
										<tr align="center">
											<td class="cellBorder">必修课</td>
											<cfloop from="1" to="#(rs_subjectEntity.schooling_length*2)#" index="termIdx">
												<td class="cellBorderPadding"><span class="number"><input name="R<cfoutput>#numberFormat(termIdx, '0_')#</cfoutput>D<cfoutput>#rs_dir.sbj_id#</cfoutput>" class="typeTinyInt" verification="double" value="<cfoutput>#progressAdvice.getCreditRequiredByTerm(termIdx)#</cfoutput>" /></span></td>
											</cfloop>
										</tr>
										<tr align="center">
											<td class="cellBorder">总学分</td>
											<cfloop from="1" to="#(rs_subjectEntity.schooling_length*2)#" index="termIdx">
												<td class="cellBorderPadding"><span class="number"><input name="A<cfoutput>#numberFormat(termIdx, '0_')#</cfoutput>D<cfoutput>#rs_dir.sbj_id#</cfoutput>" class="typeTinyInt" verification="double" value="<cfoutput>#progressAdvice.getCreditByTerm(termIdx)#</cfoutput>" /></span></td>
											</cfloop>
										</tr>
									</table>
								</div>
							
							</cfloop>
							
							<hr/>
							
							<div class="lable">
								<input class="button" type="submit" value="保存学分进度要求" />
								<input class="button" type="reset" value="重设表格" />
							</div>
						</form>
				</div>

				<div id="Charge" class="tabContent">
				
					<form id="formCharge" onSubmit="javascript:return processVerfiyForm('formCharge');" class="formWrapper" method="post" action="<cfoutput>#buildURL('programSchemaWizardChargeUpdateDo')#</cfoutput>">
						<input type="hidden" name="SubjectID" value="<cfoutput>#rs_subjectEntity.sbj_id#</cfoutput>" />
						<input type="hidden" name="Grade" value="<cfoutput>#event.getArg('Edition')#</cfoutput>" />
						
						<!--- 收费标准 --->
                        <cfset sql = "	SELECT
											c.regular,c.secondary,c.resit,c.assist,c.advanced
										FROM
											t_charge c
										WHERE
											c.chg_id = :schema " />
						
                        <cfset queryObj = new Query( datasource = application.dnsSlave ) />
                        
                        <cfset queryObj.addParam( name = "schema", value = event.getArg("Schema"), cfsqltype = "cf_sql_varchar" )/>
                        
                        <cfset rs_chargeEntity = queryObj.execute( sql=sql ).getResult()/>
                        
						<cfif rs_chargeEntity.recordCount eq 0>
								<cfset chargeRegular = 0 />
								<cfset chargeResit = 0 />
								<cfset chargeSecondary = 0 />
								<cfset chargeAssist = 0 />
								<cfset chargeAdvanced = 0 />
							<cfelse>
								<cfset chargeRegular = numberFormat(rs_chargeEntity.regular, '_.00') />
								<cfset chargeResit = numberFormat(rs_chargeEntity.resit, '_.00') />
								<cfset chargeSecondary = numberFormat(rs_chargeEntity.secondary, '_.00') />
								<cfset chargeAssist = numberFormat(rs_chargeEntity.assist, '_.00') />
								<cfset chargeAdvanced = numberFormat(rs_chargeEntity.advanced, '_.00') />
						</cfif>

						
						<div class="label">
							<b>正常修读课程</b>
							<input name="Regular" id="Regular" type="text" class="typeSmallInt" verification="double" maxlength="6" value="<cfoutput>#event.getArg('Regular', chargeRegular)#</cfoutput>" />
							<p class="notice">在这里填写单个学分的计费标准, 若针对不同课程修订方式有不同设置, 请根据实际情况在下表对应位置修改</p>
						</div>

						<div class="label">
							<b>重修课程</b>
							<input name="Resit" id="Resit" type="text" class="typeSmallInt" verification="double" maxlength="6" value="<cfoutput>#event.getArg('Resit', chargeResit)#</cfoutput>" />
						</div>
						
						<hr/>
						
						<div class="label">
							<b>其他修读方式</b>
							双学位 <input name="Secondary" id="Secondary" type="text" class="typeSmallInt" verification="double" maxlength="6" value="<cfoutput>#event.getArg('Secondary', chargeSecondary)#</cfoutput>" />
							&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
							辅修课程 <input name="Assist" id="Assist" type="text" class="typeSmallInt" verification="double" maxlength="6" value="<cfoutput>#event.getArg('Assist', chargeAssist)#</cfoutput>" />
							&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
							进修生 <input name="Advanced" id="Advanced" type="text" class="typeSmallInt" verification="double" maxlength="6" value="<cfoutput>#event.getArg('Advanced', chargeAdvanced)#</cfoutput>" />
							
							<p class="notice">如果其他专业学生跟读本专业对应课程, 其单个学分的计费标准应当单独设置. 通常这里参照 "正常修读课程" 标准进行设置</p>
						</div>
						
						<hr/>
							
						<div class="lable">
							<input class="button" type="submit" value="保存收费标准" />
							<input class="button" type="reset" value="重设表格" />
						</div>
						
					</form>
				
				</div>
				
			</div>
		</li>
	</ul>
</div>
